// eslint.config.js
import js from "@eslint/js";
import globals from "globals";
import vueParser from "vue-eslint-parser";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import vuePlugin from "eslint-plugin-vue";
import prettier from "eslint-config-prettier";

export default [
  // 基础 JS 规则
  js.configs.recommended,
  {
    files: ["**/*.{js,ts,vue}"],
    languageOptions:{
      globals:{
        ...globals.browser,
        ...globals.node,
        AudioWorkletGlobalScope: "readonly"
      }
    }
  },

  // TypeScript 配置
  {
    files: ["**/*.ts"],
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        project: "./tsconfig.json",
        extraFileExtensions: [".vue"]
      }
    },
    plugins: {
      "@typescript-eslint": tsPlugin
    },
    rules: {
      "@typescript-eslint/no-unused-vars": "error",
      "@typescript-eslint/consistent-type-imports": "warn"
    }
  },

  // Vue 3 配置
  {
    files: ["**/*.vue"],
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        parser: tsParser
      }
    },
    plugins: {
      vue: vuePlugin
    },
    rules: {
      "vue/multi-word-component-names": "off"
    }
  },

  // Prettier 集成
  prettier
];
